*** Elm113/f1.c	Sat Apr 18 15:43:36 1992
--- new/f1.c	Mon May 04 23:57:08 1992
***************
*** 1,6 ****
--- 1,12 ----
  #include "prefs.h"
+ #ifdef LATTICE
  #include <proto/dos.h>
  #include <proto/exec.h>
+ #endif
+ #ifdef DICE
+ #include <clib/dos_protos.h>
+ #include <clib/exec_protos.h>
+ #endif
  
  
  Prototype void sendmail(char *, char *);
***************
*** 94,100 ****
          sprintf(String,"sendmail <%s -f %s -R \"%s\"",MailTmp,"MAILER-DAEMON","Mail Delivery Subsystem");
        else if (SendmailVersion==SM_OTHER)
          sprintf(String,"sendmail <%s -f %s",MailTmp,"MAILER-DAEMON");
!       Execute(String,NULL,NULL);
      }
    }
  
--- 100,106 ----
          sprintf(String,"sendmail <%s -f %s -R \"%s\"",MailTmp,"MAILER-DAEMON","Mail Delivery Subsystem");
        else if (SendmailVersion==SM_OTHER)
          sprintf(String,"sendmail <%s -f %s",MailTmp,"MAILER-DAEMON");
!       Execute(String,(BPTR)NULL,(BPTR)NULL);
      }
    }
  
***************
*** 123,129 ****
          sprintf(String,"sendmail <%s -f %s -R \"%s\"",MailTmp,"MAILER-DAEMON","Mail Delivery Subsystem");
        else if (SendmailVersion==SM_OTHER)
          sprintf(String,"sendmail <%s -f %s",MailTmp,"MAILER-DAEMON");
!       Execute(String,NULL,NULL);
      }
    }
  }
--- 129,135 ----
          sprintf(String,"sendmail <%s -f %s -R \"%s\"",MailTmp,"MAILER-DAEMON","Mail Delivery Subsystem");
        else if (SendmailVersion==SM_OTHER)
          sprintf(String,"sendmail <%s -f %s",MailTmp,"MAILER-DAEMON");
!       Execute(String,(BPTR)NULL,(BPTR)NULL);
      }
    }
  }
***************
*** 145,150 ****
--- 151,161 ----
  
      I=*i_th(Number);
  
+ #ifndef NOMETAMAIL
+     if (!getenv("NOMETAMAIL") && I.NotPlain) {
+       sprintf(TBuffer,"\fExternal pager: %s, message: %d.\n","metamail",Number);
+     } else
+ #endif
      sprintf(TBuffer,"\fExternal pager: %s, message: %d.\n",Pager,Number);
      outline();
  
***************
*** 159,164 ****
--- 170,199 ----
        return;
      }
  
+ #ifndef NOMETAMAIL
+     if (!getenv("NOMETAMAIL") && I.NotPlain) {
+       j=I.ArtikelStart;
+       l=I.ArtikelEnd;
+ 
+       fseek(in,j,0);
+ 
+       while(getline(in,Text,&r) && (r<=l)) {
+         fprintf(out,"%s\n",Text);
+       }
+ 
+       CloseHomeBox(in);
+       fclose(out);
+ 
+       sprintf(Text,"metamail <* -m Elm %s",MailTmp);
+       WorkbenchToFront();
+       Execute(Text,(BPTR)NULL,(BPTR)NULL);
+       ElmToFront();
+ 
+       HandleReturns(I);
+       i_th(Number)->Status |= READ;
+       return;
+     }
+ #endif
      sprintf(Text,"Message %d/%d  From %.50s",Number,MaxArticle,I.FromName?I.FromName:I.From);
      while ((6+strlen(Text))<EXT_PAGER_WIDTH)  /* +6 (ctrl-chars, see above) -6 (length of date) */
        strcat(Text," ");
***************
*** 197,203 ****
  
      sprintf(Text,"%s %s",Pager,MailTmp);
      WorkbenchToFront();
!     Execute(Text,NULL,NULL);
      ElmToFront();
  
      HandleReturns(I);
--- 232,238 ----
  
      sprintf(Text,"%s %s",Pager,MailTmp);
      WorkbenchToFront();
!     Execute(Text,(BPTR)NULL,(BPTR)NULL);
      ElmToFront();
  
      HandleReturns(I);
***************
*** 229,236 ****
  
      I=*i_th(Number);
  
! display_page:
  
      if(!(fp=OpenHomeBox())) {
        status_msg("error: cannot open folder - mail not read",100L);
        return;
--- 264,278 ----
  
      I=*i_th(Number);
  
! #ifndef NOMETAMAIL
!     if (!getenv("NOMETAMAIL") && I.NotPlain) {
!       readmail_ext(Number,full_header);
!       return;
!     }
! #endif
  
+ display_page:
+ 
      if(!(fp=OpenHomeBox())) {
        status_msg("error: cannot open folder - mail not read",100L);
        return;
***************
*** 600,610 ****
  
  
  
! void
! forwardmail(int Number,int full_header)
  {
      FILE *in,*out;
      char String[MAX_LINELENGTH];
      char *subj;
      struct MailItem I;
  
--- 642,781 ----
  
  
  
! #ifndef NOMETAMAIL
! /*
!  * The string 'from' is going to be placed inside quotes ('"') as an
!  * argument to the CLI. Quote all characters which can be interpreted by
!  * the CLI. We currently quote '*' and '"', should any other characters be
!  * quoted?
!  */
! quoteQuotedString(char *from,char *to)
  {
+     while (*from) {
+       if (*from == '*' || *from == '"') {
+         *to++ = '*';
+       }
+       *to++ = *from++;
+     }
+     *to = 0;
+ }
+ 
+ 
+ 
+ void
+ replyMIMEmail(int Number,BOOL group_reply)
+ {
      FILE *in,*out;
      char String[MAX_LINELENGTH];
+     struct MailItem I;
+     long r;
+ 
+     if (Number<1 || Number>MaxArticle)
+       return;
+ 
+     if (!(out=fopen(MailTmp,"w"))) {
+       status_msg("error: cannot open temporary file - mail not sent",100L);
+       return;
+     }
+ 
+     I=*i_th(Number);
+ 
+     if((in=OpenHomeBox())==NULL) {
+       status_msg("error: cannot open folder - mail not sent",100L);
+       fclose(out);
+       return;
+     }
+ 
+     do_introduction(out,ReplyIntro,&I);
+ 
+     fseek(in,I.ArtikelStart,0);
+     while(getline(in,String,&r) && (r<=I.ArtikelEnd)) {
+       fprintf(out,"%s\n",String);
+     }
+     CloseHomeBox(in);
+     fclose(out);
+ 
+     putst(" ");
+     putst(MailTmp);
+ 
+     strcpy(String, "mailto <* \"");
+ 
+     if (I.ReplyTo)
+       quoteQuotedString(I.ReplyTo, String + strlen(String));
+     else
+       quoteQuotedString(I.From, String + strlen(String));
+     strcat(String, "\"");
+ 
+     if (group_reply) {
+       struct AliasItem *cc_list,*to_list,*l;
+       BOOL firstTime = TRUE;
+ 
+       to_list = list_wo_own(I.To);
+       cc_list = list_wo_own(I.Cc);
+ 
+       for (l = cc_list; l; l = l->next) {
+         if (l->alias) {
+           if (firstTime) {
+             firstTime = FALSE;
+             strcat(String, " -c \"");
+           }
+           strcat(String, " ");
+           quoteQuotedString(l->alias, String + strlen(String));
+         }
+       }
+ 
+       for (l = to_list; l; l = l->next) {
+         if (l->alias) {
+           if (firstTime) {
+             firstTime = FALSE;
+             strcat(String, " -c \"");
+           }
+           strcat(String, " ");
+           quoteQuotedString(l->alias, String + strlen(String));
+         }
+       }
+ 
+       if (!firstTime)
+         strcat(String, "\"");
+ 
+       FreeAliasList(&cc_list);
+       FreeAliasList(&to_list);
+     }
+ 
+     strcat(String, " -s ");
+     if (I.Subject==NULL || strlen(I.Subject)<1) {
+       strcat(String, "\"Re: your mail\"");
+     } else if (strnicmp(I.Subject,"Re:",3)==0) {
+       strcat(String, "\"");
+       quoteQuotedString(I.Subject, String + strlen(String));
+       strcat(String, "\"");
+     } else {
+       strcat(String, "\"Re: ");
+       quoteQuotedString(I.Subject, String + strlen(String));
+       strcat(String, "\"");
+     }
+ 
+     if (I.MessageID != NULL && strlen(I.MessageID) > 0) {
+       strcat(String, " -r \"");
+       quoteQuotedString(I.MessageID, String + strlen(String));
+       strcat(String, "\"");
+     }
+ 
+     WorkbenchToFront();
+     Execute(String,(BPTR)NULL,(BPTR)NULL);
+     ElmToFront();
+ 
+     i_th(Number)->Status |= ANSWERED;
+ }
+ #endif
+ 
+ 
+ 
+ void
+ forwardmail(int Number,int full_header)
+ {
+     FILE *in,*out;
+     char String[MAX_LINELENGTH];
      char *subj;
      struct MailItem I;
  
***************
*** 869,875 ****
      fclose(out);
  
      sprintf(exec,PipeDefault,MailTmp);
!     Execute(exec,NULL,NULL);
  /*
      Delay(100L);
      Close(fh);
--- 1040,1046 ----
      fclose(out);
  
      sprintf(exec,PipeDefault,MailTmp);
!     Execute(exec,(BPTR)NULL,(BPTR)NULL);
  /*
      Delay(100L);
      Close(fh);
***************
*** 902,908 ****
    str=malloc(strlen(MailEditor)+strlen(name)+2);
    sprintf(str,"%s %s",MailEditor,name);
    WorkbenchToFront();
!   Execute(str,NULL,NULL);
    ElmToFront();
    free(str);
  }
--- 1073,1079 ----
    str=malloc(strlen(MailEditor)+strlen(name)+2);
    sprintf(str,"%s %s",MailEditor,name);
    WorkbenchToFront();
!   Execute(str,(BPTR)NULL,(BPTR)NULL);
    ElmToFront();
    free(str);
  }
